<?
include_once('conn.php');
include_once('include/func.php');
include("admin_check.php") ;
if($admin[0][2]<>10){exit('<script>alert("您没有权限"); window.history.back(-1);</script>');}
?>	
<?
if(isset($_GET[add])){
			if($_POST[id]==null or $_POST[pw]==null){
			exit('<script>alert("输入有误"); window.history.back(-1);</script>');
			}
	$check_is_admin = $db->select("SELECT id FROM `".tablepre."admin` where id = '$_POST[id]' ");
		if($check_is_admin[0][0]==$_POST[id]){
		exit('<script>alert("管理员已经存在"); window.history.back(-1);</script>');
		}

$db->INSERT("INSERT INTO `".tablepre."admin` (`id`,`pw` ,`level`)VALUES ('".htmlspecialchars($_POST[id], ENT_QUOTES)."','".htmlspecialchars(md5($_POST[pw]), ENT_QUOTES)."','".$_POST[level]."')");
			header("Location: $nowpage?ok");
	exit();	
	}
	
	if(isset($_GET[chid])){
		$pw=$_POST[pw]<>null?' , `pw` = \''.htmlspecialchars(md5($_POST[pw]), ENT_QUOTES).'\' ':'';
		$db->UPDATE("UPDATE `".tablepre."admin` SET `id`='".htmlspecialchars($_POST[id], ENT_QUOTES)."',`level`='".$_POST[level]."' ".$pw." WHERE (`aid`='".$_GET[chid]."')");
		header("Location: $nowpage?ok&ch=".$_GET[chid]);
	exit();	
		}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo systemname;?></title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link href="css/admin.css" rel="stylesheet" type="text/css" />
	<!-- jquery packed -->
	<script type="text/javascript" src="js/jquery-1.4.4.js"></script>
    <script type="text/javascript" src="js/dtree.js"></script>
	<!-- tableRowCheckboxToggle -->
	<script type="text/javascript" src="js/tableRowCheckboxToggle.js"></script>
    <script type="text/javascript"> 
    function fade() 
{ 
    //停留2秒后消失,在停留的时候,透明度为1.0什么都不做 
    $('<div id="add" class="quick-alert">操作成功</div>').insertAfter($("#example")).animate({opacity: 1.0}, 2000).fadeOut("slow",function(){ 
   //隐藏时把元素删除 
   $(this).remove(); 
}); 
} 
</script> 
<script type="text/javascript">

function trnull(s){
	s.style.backgroundColor="";
	}
function tr1(s){
	s.style.backgroundColor="#EFEFEF";
	}
</script>
</head>
<body <? echo isset($_GET[ok])?'onload="fade();"':''; ?>>
<div id="wrap">
<div id="main" class="clearfix">
<div id="side">
  </div>
  <div id="head"><? include_once('admin_head.php');?></div>
  <div id="left"><?
  include_once('admin_menu.php');
  ?></div>
  <div id="right">
<div id="example"> </div>
<img src="images/ttfjpg.php?t=管理员设置&amp;bg=titlebg2.jpg&amp;z=18&amp;x=5&amp;y=22&amp;r=0&amp;b=0&amp;g=0"  />
<form id="form2" name="form2" method="post" action="?<? if($_GET[ch]==null){echo 'add';}elseif(isset($_GET[ch])){echo 'chid='.$_GET[ch];}?>">


<?
eval("\$str = ".parameters($con1=21));
if(isset($_GET[ch])){
	$check_admin = $db->select("SELECT * FROM `".tablepre."admin` where aid = '$_GET[ch]' ");
	}
?>
<table width="600" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td align="right" bgcolor="#666666">&nbsp;</td>
    <td bgcolor="#666666" style="color:#FFF;">管理员设置</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#F3F3F3">用户名：</td>
    <td bgcolor="#F3F3F3"><input name="id" type="text" value="<? echo $check_admin[0][1];?>"  /></td>
  </tr>
  <tr>
    <td align="right">密码：</td>
    <td><input type="text" name="pw" /><? echo isset($_GET[ch])?'不用更改时请留空':'';?></td>
  </tr>
    <tr>
    <td align="right" bgcolor="#F3F3F3">管理级别：</td>
    <td bgcolor="#F3F3F3"><select name="level" >
      <?
	  if(isset($_GET[ch])){echo '<option value="'.$check_admin[0][3].'">'.$str[$check_admin[0][3]].'</option>';}
			foreach($str as $k => $v){
				echo '<option value="'.$k.'">'.$v.'</option>';
				}
				
	?>
    </select></td>
  </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td><input type="submit" name="button2" id="button2" value="提交" /></td>
    </tr>



</table>
</form><table width="600" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td bgcolor="#666666" style="color:#FFF;">会员名</td>
    <td bgcolor="#666666" style="color:#FFF;">等级</td>
    <td bgcolor="#666666" style="color:#FFF;">操作</td>
  </tr>
  <? $admin_arr = $db->select("SELECT * FROM `".tablepre."admin` order by aid");
  for($i=0;$i<count($admin_arr);$i++) {
  ?>
  <tr onmouseover="tr1(this)" onmouseout="trnull(this);">
    <td><? echo $admin_arr[$i][1];?></td>
    <td><? echo $str[$admin_arr[$i][3]];?></td>
    <td><a href="?ch=<? echo $admin_arr[$i][0]; ?>">修改密码</a></td>
  </tr>
  <? } ?>
</table>
</div>
  </div>
  </div>

<div id="footer">
<?
include_once('fooder.php');
?>
</div>
</BODY>
</HTML>
